#!user/bin/env python3
# -- coding: utf-8 --
# @Createtime：2022/5/28
# @Updatetime：21:52
# @Author：Test008
# @File：get_text.py
# @Description：
import requests
from lxml import etree


class ip:
    url = 'https://ip.jiangxianli.com/?protocol=http'
    user_agent = {
        'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.41 Safari/537.36 Edg/101.0.1210.32'
    }
    r = requests.get(url=url, headers=user_agent).text
    anlytical = etree.HTML(r)
    title = anlytical.xpath('//*[@class="layui-table"]//tbody//td/text()')
    proxies = [title[0] + ':' + title[1]]
    http = ['http']
    proxies = dict(zip(http, proxies))
    # print(type(proxies), proxies)


def set_requests():
    proxies = {
        'http': '183.156.73.75:10080'
    }
    user_agent = {
        'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.41 Safari/537.36 Edg/101.0.1210.32'
    }
    r = requests.get(url='http://www.4399.com/', headers=user_agent, proxies=ip.proxies)
    r.encoding = 'ANSI'
    print(r.text)


if __name__ == '__main__':
    set_requests()
